/*""FILE COMMENT""*****************************************************
 *  System Name	     	: DC BrashLess Motor Control for Bootloader 
 *  File Name    	  	: UserDef.h
 *  Version        	 	: Ver 1.00
 *  Contents      	 	: 
 *  CPU          	 	: PY32F003F1x
 *  Compiler     	   	: ARM-MDK-KeilUv5
 *  OS            	 	: STM32F0
 *  Programmer	     	: E-Tool 2017.02.12
 *""FILE COMMENT END""************************************************/
 
#ifndef _ETOOL_HEADER_FILE_USER_DEFINE_
#define _ETOOL_HEADER_FILE_USER_DEFINE_

/*****************Include Header File*********************************/
#include "py32f0xx_hal.h"

//#include <stdlib.h>

//#include "CalCrc.h"

/*****************Include Header File End*****************************/
#define APP_VERSION							"TY021_PY32F003V11_230313-Demo"

/*****************Base Type Define************************************/
typedef signed int   s32;
typedef signed short s16;
typedef signed char  s8;

typedef volatile signed int   vs32;
typedef volatile signed short vs16;
typedef volatile signed char  vs8;

typedef unsigned int   u32;
typedef unsigned short u16;
typedef unsigned char  u8;

typedef volatile unsigned int   vu32;
typedef volatile unsigned short vu16;
typedef volatile unsigned char  vu8;
/*****************Base Type Define End********************************/
#define FLASHADDR_APP_VER					(0x080010E0)
/*****************Common Define***************************************/
#define GPIO_SET(x,y)						x->BSRR = y
#define GPIO_CLR(x,y)						x->BRR = y

#define GPIO_SETBIT(x,y,z)					x->BSRR = y<<(16*(1-z))

#define GPIO_CPL(x,y)						GPIO_SETBIT(x,y,(x->ODR & y)>0?0:1)	
#define GPIO_GET_IN(x,y)					((x->IDR & y)>0?1:0)

#define ON									1
#define OFF									0
	
/*****************Common Define End***********************************/
/*****************GPIO Define*****************************************/
#define GPIO_W1								GPIOB
#define BIT_W1								GPIO_PIN_5
#define GPIO_W2								GPIOF
#define BIT_W2								GPIO_PIN_1
#define GPIO_W3								GPIOF
#define BIT_W3								GPIO_PIN_0
#define GPIO_W4								GPIOB
#define BIT_W4								GPIO_PIN_7
#define GPIO_W5								GPIOA
#define BIT_W5								GPIO_PIN_12
#define GPIO_K1								GPIOB
#define BIT_K1								GPIO_PIN_6
#define GPIO_K2								GPIOF
#define BIT_K2								GPIO_PIN_2

#define GET_KEY_VAL()						((GPIO_GET_IN(GPIO_K2, BIT_K2)<<1) | GPIO_GET_IN(GPIO_K1, BIT_K1))
/*****************GPIO Define End*************************************/
/*****************User Function Switch********************************/
#define READ_PROTECT_EN						1
/*********************************************************************/
#define SET_UART2							OFF

/*****************User Function Switch End****************************/

#endif


